function questionFormBuilder(rowList = []) {
    const $form = $(`
        <form data-form="main">
            <ul data-cont="ul" class="doc-form"></ul>        
        </form>
    `)

    const $cont = $form.find('[data-cont="ul"]');
    const formRowList = [];
    build();

    return {
        $form,
        setData({rowId, rowValue}) {
            const index = formRowList.findIndex(item=>item.rowId === rowId);
            if (index===-1){
                return;
            }

            const handler = formRowList[index].handler;
            handler.val(rowValue);

        }
    }

    function build() {
        rowList.forEach(({rowId, rowMustFlag, rowPlaceholder, rowScope, rowTitle, rowType}) => {
            const $li = $(`
                <li>
                    <div class="form-key">${rowMustFlag === 1 ? `<i style="color: red">*</i> ` : ''}${rowTitle}</div>
                    <div class="form-info">
                        <input type="text" name="${rowId}" placeholder="${rowPlaceholder || ""}" class="form-text">
                    </div>
                </li>
            `)

            $cont.append($li);

            const $input = $li.find('input');
            let uploadImageHandle = "";

            switch (rowType) {
                case 1:
                    break;
                case 2:
                    $li.html(`
                        <div class="form-info">
                            <div class="upload-tit c-555">${rowMustFlag === 1 ? `<i style="color: red">*</i> ` : ''}${rowTitle}</div>
                            <textarea name="${rowId}" rows="5" placeholder="${rowPlaceholder || ""}" class="form-texa desBox" maxlength="500"></textarea>
                        </div>
                    `);

                    break;
                case 3:
                    //下拉菜单
                    $li.addClass("islink");
                    $input.attr('readonly', '1')

                    $input.on("click", () => {
                        cmpick.picker(
                            [
                                {label: "请选择", value: ""},
                                ...rowScope.split(",").map(val => {
                                    return {label: val, value: val}
                                })
                            ], {
                                title: rowTitle,
                                onConfirm: function (result) {
                                    $input.val(result[0].value);
                                },
                            }
                        )
                    })

                    break;

                case 4:
                    //时间选择器
                    $li.addClass("islink");
                    $input.attr('readonly', '1')
                    $input.on("click", () => {
                        cmpick.datePicker({
                            title: '请选择日期',
                            onConfirm: function (result) {
                                $input.val(result[0] + '-' + (result[1] < 10 ? '0' : '') + result[1] + '-' + (result[2] < 10 ? '0' : '') + result[2]);
                            },
                            id: rowId
                        });
                    })
                    break;

                case 5:
                    //图片上传控件
                    $li.html(`
                        <div class="form-info">
                            <div class="upload-tit c-555 ${rowPlaceholder ? '' : ' mb10'}">${rowMustFlag === 1 ? `<i style="color: red">*</i> ` : ''}${rowTitle}</div>
                            ${rowPlaceholder ? `<p class="c-f12 c-999 mb5">${rowPlaceholder}</p>` : ''}
                            <ul data-widget="upload" class="file-list c-photohold">
                                <input type="hidden" name="${rowId}">
                            </ul>
                        </div>
                    `);

                    const $fileInput = $li.find('input');
                    uploadImageHandle = $.uploadImageWidget({
                        $widget: $li.find(`[data-widget="upload"]`),
                        callback(imgList) {
                            $fileInput.val(imgList.join(","));
                        }
                    });

                    break;

                case 6:
                    //省份城市
                    $li.addClass("islink");
                    $input.attr('readonly', '1')
                    $input.on("click", () => {
                        $('body').append($.getCitySelect({
                            callback({provinceId, cityId, provinceName, cityName}) {
                                const name = `${provinceName || ''} ${cityName || ''}`
                                $input.val(name);
                            }
                        }));
                    });
                    break;

            }


            if (rowType === 2) {
                formRowList.push({rowId, handler: $li.find('textarea')});
            } else if (rowType === 5) {
                formRowList.push({rowId, handler: uploadImageHandle});
            } else {
                formRowList.push({rowId, handler: $li.find('input')});
            }

        })
    }

}